package com.google.code.basic.oop;
import java.util.Date;

public class Alarm {

	private int alarmId;
	private int alarmNumber;
	private int severity;
	private String alarmText;
	private String additionalInfo;
	private Date alarmTime;
	private Date clearTime;
	private Date cancelTime;
	private String sourceNe;

	public Alarm(){
		
	}
	
	public int getAlarmId() {
		return alarmId;
	}

	public int getAlarmNumber() {
		return alarmNumber;
	}

	public void setAlarmNumber(int alarmNumber) {
		if(alarmNumber < 0) { throw new AlarmRangeException("alarmNumber Value should be >= 0"); }
		else {
			this.alarmNumber = alarmNumber;
		}
	}

	public int getSeverity() {
		return severity;
	}

	public void setSeverity(int severity) {
		if(severity < 0) { throw new AlarmRangeException("severity Value should be >= 0"); }
		else {
			this.severity = severity;
		}
	}

	public Date getClearTime() {
		return clearTime;
	}

	public void setClearTime(Date clearTime) {
		if((this.getAlarmTime() != null) && (clearTime != null) && (this.getAlarmTime().after(clearTime))) {
			throw new AlarmRangeException("clearTime should be > AlarmDate");
		}
		else {
			this.clearTime = clearTime;
		}
	}

	public void setAlarmId(int alarmId) {
		if(alarmId < 0) { throw new AlarmRangeException("AlarmId Value should be >= 0"); }
		else {
			this.alarmId = alarmId;
		}
	}

	public String getAlarmText() {
		return alarmText;
	}

	public void setAlarmText(String alarmText) {
		this.alarmText = alarmText;
	}

	public String getAdditionalInfo() {
		return additionalInfo;
	}

	public void setAdditionalInfo(String additionalInfo) {
		this.additionalInfo = additionalInfo;
	}

	public Date getAlarmTime() {
		return alarmTime;
	}

	public void setAlarmTime(Date alarmTime) {
		this.alarmTime = alarmTime;
	}

	public Date getCancelTime() {
		return cancelTime;
	}

	public void setCancelTime(Date cancelTime) {
		if((this.getAlarmTime() != null) && (cancelTime != null) && (this.getAlarmTime().after(cancelTime))) {
			throw new AlarmRangeException("cancelTime should be > alarmTime");
		}
		else {
			this.cancelTime = cancelTime;
		}
	}

	public String getSourceNe() {
		return sourceNe;
	}

	public void setSourceNe(String sourceNe) {
		this.sourceNe = sourceNe;
	}


	public String toString()
	{
    
	String result = "Alarm data:  alarmId = " + getAlarmId() + " alarmNumber = " +  getAlarmNumber() + " severity = " + getSeverity() + " alarmText = " + getAlarmText() + " alarmTime = " + getAlarmTime() + " clearTime = " + getClearTime();

    return result;
	}
}


